// Copyright 2021 Guoyoko. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Engine/GameViewportClient.h"
#include "SWGameViewportClient.generated.h"

class AActor;
DECLARE_MULTICAST_DELEGATE_OneParam(FOnSelectedActor, AActor*)


/**
 * specify which GameEngine class to use in Engine ini file:
 * [/Script/Engine.Engine]
 * GameViewportClientClassName=/Script/SWEditorViewportClient.SWGameViewportClient
 */
UCLASS()
class SWEDITORVIEWPORTCLIENT_API USWGameViewportClient : public UGameViewportClient
{
	GENERATED_BODY()

public:

	USWGameViewportClient();

	virtual bool InputKey(const FInputKeyEventArgs& EventArgs) override;

	virtual void Tick(float DeltaTime) override;

	void PlaceActor(class AActor* _NewActor);

private:

	bool LineTrace(TArray<struct FHitResult>& OutHits, TArray<AActor*> IgnoredActors = TArray<AActor*>(), float LineTraceLength = 2000.f);

	void SetDroppedObjects(UObject* _Objects);

	void UpdateDroppedObject();

public:
	FOnSelectedActor DelegateOnSelectedActor;

	class APlayerController* PlayerController;

	UObject* DroppedObject;
};

extern SWEDITORVIEWPORTCLIENT_API USWGameViewportClient* GVC;

